package com.android.lazysearch;

import java.util.ArrayList;
import android.os.Parcel;
import android.os.Parcelable;

public class Restaurant implements Parcelable{
	
	private String restaurantName;
	private ArrayList<Item> restaurantItems;
	private ArrayList<Item> checkedoutItems;
	private int restaurantRating;
	private String restaurantAddress;
	private int restaurantImage;
			
	public Restaurant(String name, ArrayList<Item> items, int rating, String address, int image)
	{
		restaurantName = name;
		restaurantRating = rating; 
		restaurantAddress = address;
		restaurantImage = image;
		restaurantItems = items;
		checkedoutItems = new ArrayList<Item>();
	}
	
	public Restaurant(Parcel source)
	{	
		restaurantName = source.readString();
		checkedoutItems = new ArrayList<Item>();
		source.readTypedList(checkedoutItems, Item.CREATOR);
	}
	
	public String getRestaurantName()
	{
		return restaurantName;
	}
		
	public int getRestaurantRating()
	{
		return restaurantRating;
	}
	
	public String getRestaurantAddress()
	{
		return restaurantAddress; 
	}
	
	public int getRestaurantImage()
	{
		return restaurantImage;
	}
	
	public Item getItem(int pos)
	{
		return restaurantItems.get(pos);
	}
	
	public Item getCheckedoutItem(int pos)
	{
		return this.checkedoutItems.get(pos);
	}
	
	public ArrayList<Item> getRestaurantItems()
	{
		return restaurantItems;
	}
	
	public ArrayList<Item> getCheckedoutItems()
	{
		return checkedoutItems;
	}
	
	public int childCount()
	{
		//return restaurantItems.size();
		return checkedoutItems.size();
	}
	
	public void addToCheckedOutItems(Item i)
	{
		checkedoutItems.add(i);
	}
	
	public int getNumAddedItems()
	{
		return checkedoutItems.size();
	}
			
	@Override
	public int describeContents() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		// TODO Auto-generated method stub
		dest.writeString(restaurantName);
		dest.writeTypedList(checkedoutItems);
	}

	public static final Parcelable.Creator<Restaurant> CREATOR = new Parcelable.Creator<Restaurant>() 
	{
		public Restaurant createFromParcel(Parcel in) 
		{
			return new Restaurant(in);
		}

		public Restaurant[] newArray(int size) 
		{
			return new Restaurant[size];
		}
	};
}
